import loadComponent from "./load";

const LoadPlugin = {}

LoadPlugin.install = function(Vue,options){
    if(LoadPlugin.installed){
        return;
    }
    const tpl = Vue.extend(loadComponent)

    const loadTpl = new tpl()
    document.body.appendChild(loadTpl.$mount().$el)

    loadTpl.showLoad = false

    let show = function(obj){
        loadTpl.showLoad = true
        if(obj){
            loadTpl.loadType =  obj.type || 1
            loadTpl.loadContent = obj.content || "加载中...",
            loadTpl.modelWidth = obj.width || 100,
            loadTpl.circleColor = obj.color || "#67cf22"
        }
    }
    let hide = function(){
        loadTpl.showLoad = false
    }

    Vue.prototype.$showLoading = show
    Vue.prototype.$hideLoading = hide
}


export default LoadPlugin